package com.wanmait.recruit.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.recruit.mapper.CompanyHrReceiveResumeMapper;
import com.wanmait.recruit.mapper.EducationExpMapper;
import com.wanmait.recruit.mapper.EducationalBackgroundTypeMapper;
import com.wanmait.recruit.mapper.SchoolMapper;
import com.wanmait.recruit.pojo.*;
import com.wanmait.recruit.service.CompanyResumeService;
import com.wanmait.recruit.util.PageContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service("companyResumeService")
@Transactional(rollbackFor = Exception.class)
public class CompanyResumeServiceImpl implements CompanyResumeService {


    @Resource
    CompanyHrReceiveResumeMapper companyHrReceiveResumeMapper;

    @Resource
    EducationExpMapper educationExpMapper;

    @Override
    public PageInfo<CompanyHrReceiveResume> findByHr(int pageNum, int pageSize, CompanyHr companyHr) {
        PageHelper.startPage(pageNum,pageSize);
        List<CompanyHrReceiveResume> companyHrReceiveResumes = companyHrReceiveResumeMapper.findByHr(companyHr.getId());


        PageInfo<CompanyHrReceiveResume> pageInfo = new PageInfo<>(companyHrReceiveResumes);
        for (CompanyHrReceiveResume companyHrReceiveResume:pageInfo.getList())
        {
            Resume resume = companyHrReceiveResume.getResume();
            EducationExp educationExp = educationExpMapper.findByResumeId(resume.getId());
            companyHrReceiveResume.getResume().setEducationExp(educationExp);
        }
        return pageInfo;
    }

    @Override
    public CompanyHrReceiveResume findById(Integer id) {
        return companyHrReceiveResumeMapper.selectByPrimaryKey(id);
    }

    @Override
    public CompanyHrReceiveResume findByResume(Resume resume,Integer companyPositionId) {
        return companyHrReceiveResumeMapper.findByResumeId(resume.getId(),companyPositionId);
    }


    @Override
    public void insert(CompanyHrReceiveResume object) {
        companyHrReceiveResumeMapper.insert(object);
    }

    @Override
    public void delete(CompanyHrReceiveResume object) {
        companyHrReceiveResumeMapper.deleteByPrimaryKey(object.getId());
    }

    @Override
    public void update(CompanyHrReceiveResume object) {

    }

    @Override
    public PageInfo<CompanyHrReceiveResume> search(int pageNum, int pageSize) {
        return null;
    }
}
